from django.shortcuts import render

# Create your views here.
from django.views import View

from contents.models import ContentCategory
from goods.models import GoodsChannel
from meiduo_mall.utils.my_category import get_category


class IndexView(View):
    def get(self, request):

        categories = get_category()

        contents = {}
        content_catetories = ContentCategory.objects.all()

        for content_catetory in content_catetories:
            contents[content_catetory.key] = content_catetory.content_set.order_by("sequence")

        context = {
            "categories": categories,
             "contents": contents
        }


        return render(request, "index.html", context=context)


